| name | value | location | spawn_low | spawn_high |
|---|---|---|---|---|
| clown fish | 650 | Sea | 5 | 6 |
| ray | 3000 | Sea | 2 | 2 |
| sea butterfly | 1000 | Sea | 10 | 11 |
| golden trout | 15000 | River | 1 | 1 |
| saddled bichir | 4000 | River | 1 | 1 |
DSST 289: Introduction to Data Science
2024-09-18
mutate()if_else()case_when().html files.pdf.zip the .html.pdfKnit to .pdf option
.pdf installationIf you need to install TinyTeX
tinytex::install_tinytex()
.zip the .html (Mac)If knitting to .pdf does not work, compress your .html file like so:
Compress .html file (Mac)
.zip the .html (Windows)Instructions for Windows here.
Compress files (Windows)
What is the best way to make money fishing?
Fishing in Animal Crossing
| name | value | location | spawn_low | spawn_high |
|---|---|---|---|---|
| clown fish | 650 | Sea | 5 | 6 |
| ray | 3000 | Sea | 2 | 2 |
| sea butterfly | 1000 | Sea | 10 | 11 |
| golden trout | 15000 | River | 1 | 1 |
| saddled bichir | 4000 | River | 1 | 1 |
mutateing spawn ratesmutateing spawn rates| name | spawn_low | spawn_high | spawn_rate |
|---|---|---|---|
| salmon | 20 | 20 | 20.0 |
| pond smelt | 18 | 20 | 19.0 |
| horse mackerel | 14 | 21 | 17.5 |
| bitterling | 12 | 17 | 14.5 |
| sea bass | 11 | 18 | 14.5 |
mutate with if_else| name | spawn_rate | spawn_freq |
|---|---|---|
| frog | 8 | rare |
| black bass | 8 | rare |
mutate + case_whenA useful combination to create new variables based on multiple conditions:
| location | location_condition | n |
|---|---|---|
| Sea | NA | 10 |
| River | NA | 6 |
| Pier | NA | 4 |
| Pond | NA | 4 |
| River | clifftop | 3 |
| River | mouth | 1 |
| Sea | rainy days | 1 |
fish |>
group_by(location) |>
summarize(median_value = median(value),
mean_value = mean(value),
min_value = min(value),
max_value = max(value)) |>
arrange(desc(mean_value)) |>
kable()| location | median_value | mean_value | min_value | max_value |
|---|---|---|---|---|
| Pier | 6500 | 6875.000 | 4500 | 10000 |
| Sea | 1750 | 4381.667 | 150 | 15000 |
| River | 1400 | 3418.529 | 160 | 15000 |
| Pond | 1050 | 2035.000 | 100 | 6000 |
| caught_fish | total_caught | total_value |
|---|---|---|
| great white shark | 298 | $4,470,000 |
| blowfish | 690 | $3,450,000 |
| sturgeon | 322 | $3,220,000 |
| dorado | 212 | $3,180,000 |
| coelacanth | 191 | $2,865,000 |
| barred knifejaw | 544 | $2,720,000 |
| red snapper | 790 | $2,370,000 |
| stringfish | 147 | $2,205,000 |
| soft-shelled turtle | 556 | $2,085,000 |
| arowana | 208 | $2,080,000 |
| football fish | 783 | $1,957,500 |
| barreleye | 129 | $1,935,000 |
| golden trout | 123 | $1,845,000 |
| whale shark | 141 | $1,833,000 |
| salmon | 2617 | $1,831,900 |
| bitterling | 1871 | $1,683,900 |
| snapping turtle | 320 | $1,600,000 |
| saw shark | 132 | $1,584,000 |
| arapaima | 144 | $1,440,000 |
| Napoleonfish | 143 | $1,430,000 |
| sea butterfly | 1397 | $1,397,000 |
| koi | 345 | $1,380,000 |
| angelfish | 452 | $1,356,000 |
| giant snakehead | 243 | $1,336,500 |
| oarfish | 137 | $1,233,000 |
| char | 312 | $1,185,600 |
| gar | 197 | $1,182,000 |
| king salmon | 638 | $1,148,400 |
| mitten crab | 544 | $1,088,000 |
| hammerhead shark | 128 | $1,024,000 |
| pond smelt | 2543 | $1,017,200 |
| sweetfish | 1000 | $900,000 |
| sea horse | 801 | $881,100 |
| betta | 344 | $860,000 |
| ranchu goldfish | 184 | $828,000 |
| tilapia | 996 | $796,800 |
| cherry salmon | 791 | $791,000 |
| sea bass | 1956 | $782,400 |
| ray | 260 | $780,000 |
| loach | 1839 | $735,600 |
| catfish | 870 | $696,000 |
| ocean sunfish | 164 | $656,000 |
| piranha | 260 | $650,000 |
| butterfly fish | 580 | $580,000 |
| squid | 1126 | $563,000 |
| saddled bichir | 135 | $540,000 |
| olive flounder | 671 | $536,800 |
| moray eel | 267 | $534,000 |
| dab | 1692 | $507,600 |
| zebra turkeyfish | 938 | $469,000 |
| guppy | 347 | $451,100 |
| clown fish | 681 | $442,650 |
| goldfish | 332 | $431,600 |
| suckerfish | 274 | $411,000 |
| black bass | 1024 | $409,600 |
| nibble fish | 272 | $408,000 |
| horse mackerel | 2306 | $345,900 |
| yellow perch | 1137 | $341,100 |
| pike | 185 | $333,000 |
| rainbowfish | 333 | $266,400 |
| surgeonfish | 257 | $257,000 |
| pop-eyed goldfish | 190 | $247,000 |
| puffer fish | 965 | $241,250 |
| carp | 801 | $240,300 |
| crawfish | 1075 | $215,000 |
| dace | 841 | $201,840 |
| pale chub | 983 | $196,600 |
| bluegill | 1083 | $194,940 |
| ribbon eel | 300 | $180,000 |
| freshwater goby | 438 | $175,200 |
| crucian carp | 1065 | $170,400 |
| neon tetra | 294 | $147,000 |
| killifish | 433 | $129,900 |
| frog | 1020 | $122,400 |
| anchovy | 456 | $91,200 |
| tadpole | 737 | $73,700 |
https://fredner.org